home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / demo / client / scripts / centerPrint.cs < prev    next >
Encoding:
Text File  |  2005-11-23  |  2.2 KB  |  79 lines

  1. //-----------------------------------------------------------------------------
  2. // Torque Game Engine 
  3. // Copyright (C) GarageGames.com, Inc.
  4. //-----------------------------------------------------------------------------
  5.  
  6. $centerPrintActive = 0;
  7. $bottomPrintActive = 0;
  8.  
  9. // Selectable window sizes
  10. $CenterPrintSizes[1] = 20;
  11. $CenterPrintSizes[2] = 36;
  12. $CenterPrintSizes[3] = 56;
  13.  
  14. // time is specified in seconds
  15. function clientCmdCenterPrint( %message, %time, %size )
  16. {
  17.    // if centerprint already visible, reset text and time.
  18.    if ($centerPrintActive) {   
  19.       if (centerPrintDlg.removePrint !$= "")
  20.          cancel(centerPrintDlg.removePrint);
  21.    }
  22.    else {
  23.       CenterPrintDlg.visible = 1;
  24.       $centerPrintActive = 1;
  25.    }
  26.  
  27.    CenterPrintText.setText( "<just:center>" @ %message );
  28.    CenterPrintDlg.extent = firstWord(CenterPrintDlg.extent) @ " " @ $CenterPrintSizes[%size];
  29.    
  30.    if (%time > 0)
  31.       centerPrintDlg.removePrint = schedule( ( %time * 1000 ), 0, "clientCmdClearCenterPrint" );
  32. }
  33.  
  34. // time is specified in seconds
  35. function clientCmdBottomPrint( %message, %time, %size )
  36. {
  37.    // if bottomprint already visible, reset text and time.
  38.    if ($bottomPrintActive) {   
  39.       if( bottomPrintDlg.removePrint !$= "")
  40.          cancel(bottomPrintDlg.removePrint);
  41.    }
  42.    else {
  43.       bottomPrintDlg.setVisible(true);
  44.       $bottomPrintActive = 1;
  45.    }
  46.    
  47.    bottomPrintText.setText( "<just:center>" @ %message );
  48.    bottomPrintDlg.extent = firstWord(bottomPrintDlg.extent) @ " " @ $CenterPrintSizes[%size];
  49.  
  50.    if (%time > 0)
  51.       bottomPrintDlg.removePrint = schedule( ( %time * 1000 ), 0, "clientCmdClearbottomPrint" );
  52. }
  53.  
  54. function BottomPrintText::onResize(%this, %width, %height)
  55. {
  56.    %this.position = "0 0";
  57. }
  58.  
  59. function CenterPrintText::onResize(%this, %width, %height)
  60. {
  61.    %this.position = "0 0";
  62. }
  63.  
  64. //-------------------------------------------------------------------------------------------------------
  65.  
  66. function clientCmdClearCenterPrint()
  67. {
  68.    $centerPrintActive = 0;
  69.    CenterPrintDlg.visible = 0;
  70.    CenterPrintDlg.removePrint = "";
  71. }
  72.  
  73. function clientCmdClearBottomPrint()
  74. {
  75.    $bottomPrintActive = 0;
  76.    BottomPrintDlg.visible = 0;
  77.    BottomPrintDlg.removePrint = "";
  78. }
  79.